home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
xlibpas2.zip
/
XLA2.DOC
< prev
next >
Wrap
Text File
|
1994-06-12
|
10KB
|
206 lines
╔═══════════════════════════════════════════════════════════════════════════╗
║ ║
║ XLIB v2.0 - Graphics Library for Borland/Turbo Pascal 7.0 ║
║ ║
║ Tristan Tarrant - tristant@cogs.susx.ac.uk ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════╣
║ ║
║ Credits ║
║ ║
║ Themie Gouthas ║
║ ║
║ Matthew MacKenzie ║
║ ║
║ Tore Bastiansen ║
║ ║
║ Andy Tam ║
║ ║
║ Douglas Webb ║
║ ║
║ John Schlagel ║
║ ║
╠═══════════════════════════════════════════════════════════════════════════╣
║ ║
║ I informally reserve all rights to the code in XLIB ║
║ Rights to contributed code is also assumed to be reserved by ║
║ the original authors. ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
╔═══════════════════════════════════════════════════════════════════════════╗
║ DISCLAIMER ║
╚═══════════════════════════════════════════════════════════════════════════╝
This library is distributed AS IS. The author/s specifically disclaim any
responsibility for any loss of profit or any incidental, consequential or
other damages.
╔═══════════════════════════════════════════════════════════════════════════╗
║ XLA2 UNIT - Compression and archiving ║
╚═══════════════════════════════════════════════════════════════════════════╝
The XLA2 unit implements a set of procedures and functions to handle XLA files.
XLA stands for XLib Archive and is a very useful and powerful tool.
Suppose you just have written a game with XLib that uses many sprites, fonts
and bitmaps and you are loading all these resources from disk. This means the
program's directory is cluttered with lots of files which may take up a lot
of space. With XLA you can pack all of these files into one and extract them
from within your program at runtime. XLA files are created with the XLARC
program distributed with XLibPas2. Files inside an XLA file can be stored in
two ways (for now) : uncompressed and compressed using a variation of the LZS
algorithm. When extracting them, though, you don't have to worry about their
format : the XLA2 routines will handle all the uncompression/unpacking for you.
The structure of an XLA file is as follows :
Header
signature: array[0..3] of char= 'XLAS'
posdir : longint = The position of the archive's directory
which is at the end of the file.
sizedir : longint = The number of files stored in the archive
Files : lots of bytes = The files, stored sequentially
:
:
:
Directory : array[1..sizedir] of name : array[0..11] of char= The name
of the file
posfile : position of the file in the archive
sizefile : the original size of the file
sizecomp : the compressed size of the file
algorithm: 0 ( No compression ) 1 ( LZS compression )
XLA2 defines the following constants :
None = 0; ( No compression )
LZS = 1; ( LZS compression )
Best = 8; ( Best compression : not used yet )
In order for your program to receive the extracted data or send the raw data
to the XLA routines, you have to set up two procedural variables.
XLAOutProc : procedure( var Data; size : word );
XLAInProc : procedure( var Data; size : word; var actual : longint );
XLAOutProc will be called by the extraction routines. Data is a buffer
containing the extracted data and size is the size of the buffer in bytes.
The maximum size of the data buffer can be 64K, but if the extracted file is
bigger than that, then XLAOutProc will be called several times and your
routine should be able to handle this data.
XLAInProc will be called by the encoding routines. Your routine should put
size bytes of data in the Data buffer. If you can't provide the requested
amount of data just put the amount of bytes you copied in actual. When there
are no more bytes to compress just return a 0 in actual.
Procedures and Functions
Function XLZSSave( FName : string ) : boolean;
-----------------------------------------------
Creates a standalone file with name FName. Calls XLAInProc. Returns true
if successful, false otherwise.
Function XLZSLoad( FName : string ) : boolean;
-----------------------------------------------
Loads a standalone file with name FName. Calls XLAOutProc. Returns true if
successful, false otherwise.
function XCreateArchive( filename : string ) : boolean;
--------------------------------------------------------
Creates an XLA file for writing. Writes a template header to disk.
Returns true if successful.
function XOpenArchive( filename : string ) : boolean;
------------------------------------------------------
Opens an already existing XLA file for reading. Reads in the archive's
directory. Returns true if successful.
function XUpdateArchive( filename : string ) : boolean;
--------------------------------------------------------
Opens an already existing XLA file for writing/reading. Reads in the archive's
directory. Returns true if successful.
function XCloseArchive : boolean;
----------------------------------
This function has to be called when the program doesn't need to access the
XLA file any more. If the archive was opened with XCreateArchive or
XUpdateArchive the the XEndArchive function must be called instead,
otherwise the XLA file will be corrupt. Frees all the memory allocated to
the uncompression routines. Returns true if successful.
function XEndArchive : boolean;
--------------------------------
This function has to be called when the program has finished creating or
updating an archive. It writes the archive's directory at the end of the
file and updates the header to reflect any changes. Frees all memory
allocated to the compression routines. Returns true if successful.
function XLAGet( fname : string ) : boolean;
---------------------------------------------
Extracts a file from the currently open archive. Calls XLAOutProc.
Returns true if successful.
function XLAPut( fname : string; mode : word ) : boolean;
----------------------------------------------------------
Adds a file to the currently open archive. Calls XLAInProc. Returns true
if successful. Mode can be either None or LZS.
procedure XPrintDir;
--------------------
Displays a formatted list of all the files contained in the archive.
function XLAGetFileInfo( fname : string;